package 
{
	import flash.display.*;
	import flash.events.Event;
	import flash.events.KeyboardEvent;
	import flash.ui.Keyboard;
	
	import org.flashbrighton.as3bots.controllers.GameController;
	import org.flashbrighton.as3bots.models.GameModel;
	import org.flashbrighton.as3bots.views.GameView;
	
	
	[SWF(width="800", height="500", frameRate="30")] //backgroundColor="#000000"
	
	
	public class Main extends Sprite
	{
		private var _model:GameModel;
		private var _controller:GameController;
		private var _view:GameView;
		
		
		public function Main()
		{
			setStage();
			setGame();
			addEventListener(Event.ADDED_TO_STAGE, initKeyboard);
		}
		
		
		private function setStage():void
		{
			//stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.align = StageAlign.TOP_LEFT;
		}
		
		
		private function setGame():void
		{			
			_model = new GameModel();
			_view = new GameView(_model);
			_controller = new GameController(_model, _view);
			
			addChild(_view);
		}
 		
 		
 		private function initKeyboard(e:Event):void
 		{
 			stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
 		}
 		
 		
 		private function onKeyDown(k:KeyboardEvent):void
 		{
 			switch (k.keyCode)
 			{
 				case Keyboard.SPACE:
 				_view.names.visible = false;
 				_model.isPlaying = true;
 				break;
 			}
 		}
 		
	}
	
}
